<div id="all_view"> 
<?php
if(!@$_GET['search']){
	$view_friend = '<div id="title" style="background:#f6f7f8 url(images/friend_all.jpg) no-repeat left"><h2>Bạn bè &nbsp;·</h2> &nbsp; '.$total_friend.'<div style="clear:both; height:1px"></div></div>
	<div id="friend">';
	for($i=0; $i<$total_friend; $i++){
		$user_friend = $tc->view_friends($m[$i]);
		$row_user_friend = mysql_fetch_array($user_friend);
		$m2 = explode(',',$row_user_friend['friend']);
		$total_user_friend = count($m2)-1;
		$view_friend .= '<div class="item"><a href="index.html?user='.$row_user_friend['id'].'"><img src="'.url_hinh_user_130x130.$row_user_friend['avatar'].'.jpg" alt=""><h4>'.$row_user_friend['name'].'</h4></a><p>'.$total_user_friend.' bạn bè</p></div>';
	}
	echo $view_friend.'<div style="clear:both"></div></div>'; mysql_free_result($friend);
}else{
	$str = $_GET['search'];
	$view_friend = '<div id="title" style="background:#f6f7f8 url(images/friend_all.jpg) no-repeat left"><h2>Tìm kiếm bạn bè theo: '.$str.'</h2><div style="clear:both; height:1px"></div></div>
	<div id="friend">';
	$user_friend = $tc->search($str);
	$total_user_friend = mysql_num_rows($user_friend);
	if($total_user_friend > 0){
		while($row_user_friend = mysql_fetch_array($user_friend)){
			$view_friend .= '<div class="item"><a href="index.html?user='.$row_user_friend['id'].'"><img src="'.url_hinh_user_130x130.$row_user_friend['avatar'].'.jpg" alt=""><h4>'.$row_user_friend['name'].'</h4></a><p>'.$row_user_friend['hocvan'].'</p><p>'.$row_user_friend['congviec'].'</p></div>';
		}
		echo $view_friend.'<div style="clear:both"></div>';
		mysql_free_result($friend);
	}else echo $view_friend.'Không tìm thấy kết quả theo từ: '.$str;
	echo '</div>';
}
?>
</div>